package ${prefixPackage}.controller;

<#if !isSimple>
import ${prefixPackage}.beans.vo.${javaNameBig}Vo;
import ${prefixPackage}.beans.request.${javaNameBig}AddRequest;
import ${prefixPackage}.beans.request.${javaNameBig}EditRequest;
import ${prefixPackage}.beans.request.${javaNameBig}ListRequest;
import ${prefixPackage}.service.${javaNameBig}Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xinecai.common.api.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
</#if>
<#if isSimple>
import ${prefixPackage}.service.${javaNameBig}Service;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
</#if>

/**
 * ${tbDesc}Controller层
 *
 * @author ${author}
 * @date ${date}
 */
@Slf4j
@Api(tags = "${tbDesc}")
@RestController
@RequestMapping("/${javaName?lower_case}")
public class ${javaNameBig}Controller {
    @Resource
    private ${javaNameBig}Service ${javaName}Service;
<#if !isSimple>

    @ApiOperation("${tbDesc}-分页列表查询")
    @GetMapping("/list")
    public Result<IPage<${javaNameBig}Vo>> queryPageList(${javaNameBig}ListRequest param) {
        return Result.ok(${javaName}Service.listWithPage(param));
    }

    @ApiOperation("${tbDesc}-添加")
    @PostMapping("/add")
    public Result<Long> add(@Validated @RequestBody ${javaNameBig}AddRequest addRequest) {
        return Result.ok(this.${javaName}Service.add${javaNameBig}(addRequest));
    }

    @ApiOperation("${tbDesc}-编辑")
    @PostMapping("/edit")
    public Result edit(@Validated @RequestBody ${javaNameBig}EditRequest editRequest) {
        this.${javaName}Service.edit${javaNameBig}(editRequest);
        return Result.ok();
    }

    @ApiOperation("${tbDesc}-通过id删除")
    @PostMapping("/delete")
    public Result delete(@RequestParam(name = "id") Long id) {
        this.${javaName}Service.removeByIdLogic(id);
        return Result.ok();
    }

    @ApiOperation("${tbDesc}-通过id查询")
    @GetMapping("/queryById")
    public Result<${javaNameBig}Vo> queryById(@RequestParam(name = "id") Long id) {
        return Result.ok(${javaName}Service.getDTO(id));
    }
</#if>
}
